package com.qiaoba.mq.rabbit;

import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.AmqpTemplate;

/**
 * RabbitMQ消息发送工具
 *
 * @author ailanyin
 * @date 2023-09-03 17:36:45
 */
@RequiredArgsConstructor
public class RabbitMqSender {

    private final AmqpTemplate rabbitTemplate;

    /**
     * 发送消息
     *
     * @param exchange   交换机(可以为空串)
     * @param routingKey 路由Key
     * @param message    消息内容
     */
    public void sendMessage(String exchange, String routingKey, String message) {
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
    }
}
